package com.ruoyi.web.controller.salary;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Salary;
import com.ruoyi.system.service.ISalaryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2025-04-19
 */
@RestController
    @RequestMapping("/system/salary")
public class SalaryController extends BaseController
{
    @Autowired
    private ISalaryService salaryService;

    @GetMapping("/salary/list")
    public Map list(@RequestParam Long usersid,
                       @RequestParam int page,
                       @RequestParam int limit
                       ) {

        int offset = (page - 1) * limit;
        List<Salary> salaryList = salaryService.selectSalaryListByUsersId(usersid, offset, limit);
        int totalCount = salaryService.countSalaryByUsersId(usersid);
        Map modelMap = new HashMap();
        modelMap.put("salaryList", salaryList);
        modelMap.put("totalCount", totalCount);
        modelMap.put("usersid", usersid);
        modelMap.put("page", page);
        modelMap.put("limit", limit);

        return modelMap;
    }

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:salary:list')")
    @GetMapping("/list")
    public TableDataInfo list(Salary salary)
    {
        startPage();
        List<Salary> list = salaryService.selectSalaryList(salary);
        return getDataTable(list);
    }

    @GetMapping("/mylist")
    public TableDataInfo mylist(Salary salary)
    {
        startPage();
        List<Salary> list = salaryService.selectSalaryList(salary);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:salary:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Salary salary)
    {
        List<Salary> list = salaryService.selectSalaryList(salary);
        ExcelUtil<Salary> util = new ExcelUtil<Salary>(Salary.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:salary:query')")
    @GetMapping(value = "/{salaryis}")
    public AjaxResult getInfo(@PathVariable("salaryis") Long salaryis)
    {
        return success(salaryService.selectSalaryBySalaryis(salaryis));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:salary:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Salary salary)
    {
        return toAjax(salaryService.insertSalary(salary));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:salary:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Salary salary)
    {
        return toAjax(salaryService.updateSalary(salary));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:salary:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{salaryiss}")
    public AjaxResult remove(@PathVariable Long[] salaryiss)
    {
        return toAjax(salaryService.deleteSalaryBySalaryiss(salaryiss));
    }
}
